<?php
function sendToHost($host,$method,$data,$contentType,$acceptType)
//send json or text data to API
{
    $ch = curl_init($host);
    //curl_setopt($ch, CURLOPT_MUTE, TRUE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:'.$contentType,'Accept: '.$acceptType,'Content-length:'.strlen($data)));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($ch);
    if(curl_errno($ch))
        print curl_error($ch);
    else
        curl_close($ch);
//    echo "<br/>Output= ".$output;  //UNIT_TESTING
//    echo "<br>".$host."<br>"; //UNIT_TESTING
//    echo $data;  //UNIT_TESTING
	return $output;
}

?>